<!--
 * @Description: 
 * @Author: shizhe
 * @Date: 2022-03-30 14:40:06
 * @LastEditTime: 2022-04-19 11:01:56
 * @LastEditors: shizhe
 * @Reference: 
-->
<template>
  <div id="com_square">
    <h1>企业相册</h1>
    <div class="nocontent_bg" v-show="!total">
      <el-image :src="require('@/assets/role_bg2.png')"></el-image>
      <p style="color: #999999">暂无企业相册</p>
    </div>
    <div class="img_box">
      <el-image
        class="img_item"
        :src="item.fileAddress"
        v-for="(item, index) in imgList"
        :key="index"
        :style="{ marginRight: (index + 1) % 2 == 0 ? '0' : '20px' }"
      ></el-image>
    </div>
    <div class="pag_box" v-show="total">
      <element-pagination
        :Total="total"
        @getData="getPagChange"
        :Layout="'total,  prev, pager, next, jumper'"
        :Size="4"
      ></element-pagination>
    </div>
  </div>
</template>

<script>
import ElementPagination from '../../../components/ElementPagination.vue'
export default {
  components: { ElementPagination },
  props: {
    id: {
      type: [String, Number]
    }
  },
  data() {
    return {
      imgList: [],
      page: 1,
      size: 4,
      total: 0
    }
  },
  mounted() {
    this.getImgList()
  },
  watch: {
    id() {
      this.getImgList()
    }
  },
  methods: {
    getPagChange(data) {
      this.page = data.currentPage
      this.size = data.pagesize
      this.getImgList()
    },
    getImgList() {
      this.$https({
        method: 'post',
        url: '/enterpriseInfo/getPhotoAlbumList',
        data: {
          page: this.page,
          size: this.size,
          enterpriseId: this.id
        }
      }).then(res => {
        if (res.code == 0) {
          this.imgList = res.data.records || []
          this.total = res.data.total || 0
        } else {
          this.$message.error(res.msg)
        }
      })
    }
  }
}
</script>
<style lang="less" scoped>
#com_square {
  padding: 20px 20px 0 20px;
  border: 1px solid #d6d6d6;
  border-top: none;
  // height: 962px;
  // overflow-y: auto;
  // position: relative;
  h1 {
    font-size: 16px;
    font-weight: 500;
    color: #333;
    padding-left: 10px;
    border-left: 4px solid #fa7355;
    span {
      font-weight: normal;
      color: #999;
    }
  }
  .img_box {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    .img_item {
      width: 567px;
      height: 554px;
      background: #f2f3f7;
      border: 1px solid #f2f3f7;
      margin-bottom: 20px;
    }
  }
  .pag_box {
    // position: sticky;
    // background-color: #fff;
    // bottom: 0px;
    padding-bottom: 20px;
    padding-top: 20px;
    /deep/ .el-pagination {
      margin-top: 0;
    }
  }
  .nocontent_bg {
    height: 228px;
  }
}
</style>
